wrap yaml into main to avoid it auto-running on validate through the import#163
wrap yaml into main to avoid it auto-running on validate through the import#163CIGbalance wants to merge 4 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR prevents yaml_to_html.py from executing its YAML→HTML generation logic on import (e.g., when utils/validate_yaml.py imports default_columns), by moving runtime behavior behind a __main__ guard.
Changes:
- Wrapped YAML loading, table generation, and HTML file writing in
if __name__ == "__main__":. - Moved
default_columnsto module scope so it remains importable without triggering generation. - Minor formatting adjustments (e.g., multiline
hrefassignment,to_htmlcall formatting).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| data = pd.json_normalize(yaml.safe_load(yaml_input)) | ||
|
|
||
|
|
||
| if all_columns is False: |
There was a problem hiding this comment.
Within this block, if all_columns is False: is a non-idiomatic boolean check and reduces readability. Prefer if not all_columns: (or just if all_columns: where appropriate) for consistency with typical Python style.
| if all_columns is False: | |
| if not all_columns: |
|
|
||
|
|
There was a problem hiding this comment.
There are multiple consecutive blank lines/whitespace-only lines after loading the YAML (between the with open(...) block and the next if), which adds noise in the main flow. Please remove the extra blank lines to keep the script compact and consistent with the surrounding style.
|
Change will be added by @Dvermetten somewhere else |
This pull request refactors the
yaml_to_html.pyscript to improve code structure, readability, and maintainability. The main changes involve moving data loading and processing into a__main__guard, reformatting code for clarity, and making minor improvements to table generation.Code organization and structure:
if __name__ == "__main__":block to prevent accidental execution when the module is imported.linkify_cellfunction and table generation. [1] [2]Data loading and processing: